{-# LANGUAGE TemplateHaskell, QuasiQuotes, OverloadedStrings #-}
module Handler.Root where

import Foundation
import Settings.StaticFiles

import Handler.Common hiding ( mainHeader, newDefaultLayout )

-- This is a handler function for the GET request method on the RootR
-- resource pattern. All of your resource patterns are defined in
-- config/routes
--
-- The majority of the code you will write in Yesod lives in these handler
-- functions. You can spread them across multiple files if you are so
-- inclined, or create a single monolithic file.
getRootR :: Handler RepHtml
getRootR = do

--    mu <- maybeAuth

    newDefaultLayout $ do

        setTitle "WSO-UV"

        addWidget $(widgetFile "home")


newDefaultLayout :: Widget -> Handler RepHtml
newDefaultLayout widget = do
        mmsg <- getMessage
        pc   <- widgetToPageContent $ do

                   addStylesheet $ StaticR css_default_css
                   addScript     $ StaticR js_jquery_js
                   addScript     $ StaticR js_plusstrap_js
                   addScript     $ StaticR js_application_js

                   $(widgetFile "default-layout-new")


        hamletToRepHtml $(hamletFile "default-layout-wrapper")

mainHeader :: Widget
mainHeader = [whamlet|

<div .container> 
    <h1>
        <img .hidden-phone src=@{ StaticR img_logo_bw_2_png }>
        <span>The World Space Observatory Ultraviolet</span>

    <!--            
    <div .div-search>
        <form .form-search>
           <input type="text" .input .search-query>

           <button type="submit" .btn .btn-primary>
             <i .icon-search .icon-white></i>
   -->
   
|]